# 宏定义和函数定义的相同点
# 定义函数
Function(myfunction ag1 ag2 ag3)
    message(STATUS "function ag is " ${ag1})
    message(STATUS "function ag is " ${ag2})
    message(STATUS "function ag is " ${ag3})
endfunction(myfunction)


# 定义宏
macro(mymacro ag1 ag2 ag3)
    message(STATUS "macro ag is " ${ag1})
    message(STATUS "macro ag is " ${ag2})
    message(STATUS "macro ag is " ${ag3})
endmacro(mymacro)

# 调用函数
myfunction(1 2 3 4 5)

message(STATUS "\n")

# 调用宏
mymacro(1 2 3 4 5)


message(STATUS "不同点 ==================>")
# 宏定义和函数的不同点
macro(_bar)
    message(STATUS "this is in macro bar " ${ARGN})

    set(aa ${ARGV0})
    if(ARGV0)
        message(STATUS "this is in a 1")
    endif()
    if(aa)
        message(STATUS "this is in a 2 " ${aa})
    endif()

    set(list_var ${ARGN})
    foreach(arg IN LISTS ARGN)
        message(STATUS "this is in macro 2 ${arg}")
    endforeach()
    foreach(arg ${ARGN})
        message(STATUS "this is in macro 3 ${arg}")
    endforeach()
    foreach(arg IN LISTS list_var)
        message(STATUS "this is in macro 4 ${arg}")
    endforeach()
endmacro(_bar)

message(STATUS "\n")
_bar(a b c)

function(_func)
    message(STATUS "this is in func __func " ${ARGN})

    set(aa ${ARGV0})
    if(ARGV0)
        message(STATUS "this is in a 1 " ${ARGV0})
    endif()
    if(aa)
        message(STATUS "this is in a 2 " ${aa})
    endif()

    set(list_var ${ARGN})
    foreach(arg IN LISTS ARGN)
        message(STATUS "this is in __func 2 ${arg}")
    endforeach()
    foreach(arg IN LISTS list_var)
        message(STATUS "this is in __func 3 ${arg}")
    endforeach()
endfunction(_func)

message(STATUS "\n")
_func(d e f)

# cmake -P macro_function.cmake